package com.cade.agriculturemall.view.shoppingCar.settlement.TicketSelectDialog;

import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.TextView;

import com.cade.agriculturemall.R;
import com.cade.agriculturemall.base.BaseAdapter;
import com.cade.agriculturemall.base.BaseViewHolder;
import com.cade.agriculturemall.model.Ticket;
import com.cade.agriculturemall.utils.ConverUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hshunxin on 2018/2/27.
 */

public class TicketSelectAdapter extends BaseAdapter<BaseViewHolder>  {
    private List<Ticket> tickets = new ArrayList<>();


    @Override
    public void onBindViewHolderWrapper(BaseViewHolder holder, int position) {
        TextView tvTitle = holder.findViewById(R.id.discount_title_tv);
        TextView tvContent = holder.findViewById(R.id.discount_content_tv);
        TextView tvTime = holder.findViewById(R.id.discount_time_tv);
        Ticket entity = (Ticket) tickets.get(position);
        tvTitle.setText("￥" + entity.getMoney() + "元" + entity.getType());
        tvContent.setText(entity.getContent());
        tvTime.setText("截止日期:" + ConverUtil.dateToStrLong(entity.getStartTime()) + "-" + ConverUtil.dateToStrLong(entity.getEndTime()));
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new BaseViewHolder(parent, R.layout.my_discount_item);
    }
    @Override
    public int getItemCount() {
        return tickets.size();
    }

    public void setList(List<Ticket> tickets) {
        this.tickets = tickets;
    }
}
